<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%	String error = (String) session.getAttribute("error");
	session.removeAttribute("error");%>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="google-signin-clientid" content="200831826702-javfst7ignashgjschib6osh972ruhhc.apps.googleusercontent.com" />
	<meta name="google-signin-scope" content="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read https://www.googleapis.com/auth/plus.me" />
	<meta name="google-signin-requestvisibleactions" content="http://schemas.google.com/AddActivity" />
	<meta name="google-signin-cookiepolicy" content="single_host_origin" />
	    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>TiVendoIo</title>

    <!-- Bootstrap -->
    <link href="/serviceTechnologies/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.css" rel="stylesheet">
    <link href="css/style.css" rel = "stylesheet">
    
    <script type="text/javascript">
	$(document).ready(function(){
		$('#footer').load('/serviceTechnologies/common/footer.jsp');
	});
	</script>

	
	<script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : '222737361268089',
          status     : false,
          xfbml      : true
        });
        
     	
        
      };

      (function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement(s); js.id = id;
         js.src = "//connect.facebook.net/it_IT/all.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'facebook-jssdk'));
      
      
      function loginFB () {
    	 
    	  FB.login(function(response) {
    		   if (response.authResponse) {
    		     
    		     FB.api('/me', function(response) {
    		       window.location="./SocialNetworkLogin?id=" + response.id + "&social=Facebook";
    		       //location.href = "./FACEBOOKsignin?id=" + response.id;
    		     });
    		   } else {
    		     console.log('User cancelled login or did not fully authorize.');
    		   }
    		 });
    	  
      };
      
		
      (function() {
    	  var po = document.createElement('script');
    	  po.type = 'text/javascript'; po.async = true;
    	  po.src = 'https://apis.google.com/js/client:plusone.js';
    	  var s = document.getElementsByTagName('script')[0];
    	  s.parentNode.insertBefore(po, s);
    	})();
      
      function GLogin() {
    	  var initializedGoogleCallback = false;
    	  window.removeEventListener('load')
    	  gapi.auth.signIn({
    	    'callback': function (authResult) {
    	       if (!initializedGoogleCallback) {
    	         // after first call other will be ignored
    	         initializedGoogleCallback = true;
    	         if (authResult['status']['signed_in']) {
    	        	 gapi.client.load('plus','v1', loadProfile);
    	         } else {
    	        	 alert('Error');
    	         }
    	       }
    	    }
    	  });
    	}
      
  	function loadProfile(){
  	    var request = gapi.client.plus.people.get( {'userId' : 'me'} );
  	    request.execute(loadProfileCallback);
  	  }
  	function loadProfileCallback(obj) {
  		window.location="./SocialNetworkLogin?id=" + obj['id'] + "&social=Google";
  	  }
  
    </script>

	
	
	
	
  </head>
  <body>
    
    <!--  Facebook connection -->
    <div id="fb-root"></div>
   
    
	<div class="container">
    
    <div id = "logo">
   		<h3><a href="#">TiVendoio</a></h3>
   </div>
   

    <div class="omb_login">
    	<h3 class="omb_authTitle">Login or <a href="registration.jsp">Sign up</a></h3>
		<div class="row omb_row-sm-offset-3 omb_socialButtons">
    	    <div class="col-xs-4 col-sm-2">
		        <a onclick="loginFB()" class="btn btn-lg btn-block omb_btn-facebook">
			        <i class="fa fa-facebook visible-xs"></i>
			        <span class="hidden-xs">Facebook</span>
		        </a>
	        </div>
        	<div class="col-xs-4 col-sm-2">
		        <a href="./TWITTERsignin?scope=login" class="btn btn-lg btn-block omb_btn-twitter">
			        <i class="fa fa-twitter visible-xs"></i>
			        <span class="hidden-xs">Twitter</span>
		        </a>
	        </div>	
        	<div class="col-xs-4 col-sm-2">
        		<div id = "GLogin" onclick="GLogin()">
			        <a  class="btn btn-lg btn-block omb_btn-google">
				        <i class="fa fa-google-plus visible-xs"></i>
				        <span class="hidden-xs">Google+</span>
			        </a>
		        </div>
	        </div>	
		</div>

		<div class="row omb_row-sm-offset-3 omb_loginOr">
			<div class="col-xs-12 col-sm-6">
				<hr class="omb_hrOr">
				<span class="omb_spanOr">or</span>
			</div>
		</div>

		<div class="row omb_row-sm-offset-3">
			<div class="col-xs-12 col-sm-6">	
			    <form class="omb_loginForm" action="./NormalLogin" autocomplete="off" method="POST">
					<div class="input-group">
						<span class="input-group-addon"><i class="fa fa-user"></i></span>
						<input type="text" class="form-control" name="email" placeholder="email address">
					</div>
					<span class="help-block"></span>
										
					<div class="input-group">
						<span class="input-group-addon"><i class="fa fa-lock"></i></span>
						<input  type="password" class="form-control" name="password" placeholder="Password">
					</div>
                    <span class="help-block"></span>

					<button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
				</form>
			</div>
    	</div>
		<div class="row omb_row-sm-offset-3">
			<div class="col-xs-12 col-sm-3">
				<label class="checkbox">
					<input type="checkbox" value="remember-me">Remember Me
				</label>
			</div>
			<div class="col-xs-12 col-sm-3">
				<p class="omb_forgotPwd">
					<a href="#">Forgot password?</a>
				</p>
			</div>
		</div>	    	
	</div>
    </div>
    
    <div id="footer"></div>
    
    <% if(error!=null){
 			if(error.equals("yes")){%>
 				<script type="text/javascript">alert("Login Error")</script>
 			<%}
 		} %>
	
  </body>
</html>